Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x 5x 5x 5x 2x 3x 3x | import { NextRequest, NextResponse } from "next/server";
import { ShareController } from "@/server/api/shares";
import { getDb } from "@/lib/db";
export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ token: string }> }
) {
try {
const { token } = await params;
const db = getDb();
const share = await ShareController.fromDb(db).viewSharedResult(token);
return NextResponse.json(share);
} catch (error) {
// Public route: never echo the underlying error to an unauthenticated caller
// (it carries driver text, constraint names, sometimes values). Log, return generic.
console.error("shared-results view failed", error);
return NextResponse.json(
{ error: "That shared result isn't available." },
{ status: 404 }
);
}
}
|